package com.example.myapplication.markwon

import io.noties.markwon.MarkwonConfiguration
import io.noties.markwon.RenderProps
import io.noties.markwon.SpanFactory
import io.noties.markwon.core.CoreProps

/**
 * Create by Tanzhenxing on 2025/7/1.
 * Description:
 */
class ListItemSpanFactory : SpanFactory{
    override fun getSpans(configuration: MarkwonConfiguration, props: RenderProps): Any? {
        return if (CoreProps.ListItemType.BULLET == CoreProps.LIST_ITEM_TYPE.require(props)) {
            BulletListItemSpan(configuration.theme(), CoreProps.BULLET_LIST_ITEM_LEVEL.require(props))
        } else {
            val number = "${CoreProps.ORDERED_LIST_ITEM_NUMBER.require(props)}.\u00a0"
            OrderedListItemSpan(configuration.theme(), number)
        }
    }
}